package com.driver;

class A {
	void a() {
		System.out.println("A");
	}
}

class B extends A {
	void a() {
		System.out.println("B");
	}
}

class C extends A {
	void a() {
		System.out.println("C");
	}
}

public class classForNameDriver {
	public static void main(String[] args) {
		classForNameDriver ct = new classForNameDriver();
		ct.showName("com.driver.B");
	}

	private void showName(String name) {
		A a;
		try {
			a = (A) Class.forName(name).newInstance();
			a.a();
		} catch (InstantiationException e) {
			e.printStackTrace();
		} catch (IllegalAccessException e) {
			e.printStackTrace();
		} catch (ClassNotFoundException e) {
			e.printStackTrace();
		}

	}

}
